<template>
	<view>
		<view class="title">平台将会严格保护您的信息安全</view>
		<view class="form-main">
			<uni-forms :modelValue="userForm" ref="companyRef" :rules="companyRules">
				<view>
					<uni-forms-item label="真实姓名" label-width="90">
						<uni-easyinput maxlength="20" placeholder="请输入真实姓名" v-model="userForm.realname"
							:inputBorder="false"></uni-easyinput>
					</uni-forms-item>
					<uni-forms-item label="身份证号码" label-width="90">
						<uni-easyinput type="idcard" maxlength="18" placeholder="请输入身份证号码" v-model="userForm.cardId"
							:inputBorder="false"></uni-easyinput>
					</uni-forms-item>
					<view class="row" style="justify-content: flex-start;margin-top: 20rpx">
						<checkbox-group @change="isChecked = !isChecked" style="width: auto">
							<checkbox color="#2872FD" style="transform:scale(0.7);" :checked="isChecked" shape="circle">
							</checkbox>
						</checkbox-group>
						<view style="display: inline-block;">我已阅读并同意 <text style="color: #2872FD;"
								@click="toAgreement">《实名认证服务协议》</text></view>
					</view>
				</view>
			</uni-forms>
		</view>
		<view class="footer-btn">
			<button :loading="submitLoading" type="primary" @click="onSubmit">提交</button>
		</view>
	</view>

</template>

<script>
export default {
	data() {
		return {
			userForm: {
				realname: '',
				cardId: ''
			},
			companyRules: {

			},
			isChecked: false,
			submitLoading: false
		};
	},
	// #ifdef MP-WEIXIN
	options: {
		styleIsolation: 'shared' // 解除样式隔离
	},
	// #endif
	methods: {
		onSubmit() {
			if (!this.submitLoading) {
				if (!this.isChecked) {
					return this.$util.Tips('请先同意授权协议')
				}
				if (!this.userForm.realname) {
					return this.$util.Tips('请输入真实姓名')
				}
				const reg =
					/(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0[1-9]|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/;
				if (!reg.test(this.userForm.cardId)) {
					return this.$util.Tips('请输入正确的身份证号码')
				}
				this.submitLoading = true

				let url = window.location.href
				let replacedUrl = url.replace("/livenessView/livenessView", "/callPage/callPage");
				const callBackUrl = encodeURIComponent(replacedUrl)
				let params = {
					...this.userForm,
					callbackUrl: callBackUrl,
				}
				console.log("params", params)
			}


			// uni.navigateTo({
			// 	url: '/pageUser/startBind/startBind'
			// })

		},
		toAgreement() {
			uni.navigateTo({
				url: '/pages/privacy/index?privacyType=3'
			})
		}
	}
}
</script>

<style lang="scss">
page {
	background-color: #f5f5f5;
}

/deep/ .uni-forms-item__label {
	font-size: 24rpx;
}

.title {
	text-align: center;
	margin: 50rpx;
}

.form-main {
	width: 93%;
	margin: 30rpx;
}

.uni-forms-item {
	border-radius: 20rpx;
	height: 88rpx;
	line-height: 88rpx;
}

/deep/ .uni-easyinput__content {
	height: 88rpx;
	line-height: 88rpx;
}

/deep/ .uni-forms-item__label {
	height: 88rpx;
	line-height: 88rpx;
}

/deep/ .uni-forms-item {
	background-color: #fff;
	padding: 0 30rpx;
}

/deep/ .uni-input-input {
	text-align: -webkit-right;
	text-align: right;
}

/deep/ .uni-input-placeholder {
	// padding-left: 165rpx;
}

/deep/ .uni-easyinput__placeholder-class {
	text-align: right;
}

.footer-btn {
	width: 93%;
	position: fixed;
	left: 50%;
	bottom: 20rpx;
	transform: translateX(-50%);
	border-radius: 42rpx;
	overflow: hidden;
}
</style>